﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" Src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" Src="~/_controltemplates/ToolBarButton.ascx" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PropertiesEdit.aspx.cs"
    Inherits="SPPropertyBagManagement.Layouts.SPPropertyBagManagement.PropertiesEdit"
    DynamicMasterPageFile="~masterurl/default.master" MaintainScrollPositionOnPostback="true" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <script type="text/javascript">
        function openSingleEditDialog(propertyId, scope, objectId, itemId) {
            var options = SP.UI.$create_DialogOptions();
            options.url = 'SingleEdit.aspx?PropertyName=' + propertyId + '&Scope=' + scope + '&Id=' + objectId + '&ItemId=' + itemId;
            options.height = 300;
            options.width = 590;
            options.allowMaximize = false;
            options.dialogReturnValueCallback = refreshCurrentLocation;

            SP.UI.ModalDialog.showModalDialog(options);
        }

        function openNewPropertyDialog(scope, objectId, itemId) {
            var options = SP.UI.$create_DialogOptions();
            options.url = 'New.aspx?Scope=' + scope + '&Id=' + objectId + '&ItemId=' + itemId;
            options.height = 330;
            options.width = 600;
            options.allowMaximize = false;
            options.dialogReturnValueCallback = refreshCurrentLocation;

            SP.UI.ModalDialog.showModalDialog(options);
        }

        function openDeleteDialog(propertyId, scope, objectId, itemId) {
            var options = SP.UI.$create_DialogOptions();
            options.url = 'Delete.aspx?PropertyName=' + propertyId + '&Scope=' + scope + '&Id=' + objectId + '&ItemId=' + itemId;
            options.height = 230;
            options.width = 450;
            options.allowMaximize = false;
            options.dialogReturnValueCallback = refreshCurrentLocation;

            SP.UI.ModalDialog.showModalDialog(options);
        }

        function refreshCurrentLocation() {
            window.location = window.location;
        }

        if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' && _spBodyOnLoadFunctionNames != null) {
            _spBodyOnLoadFunctionNames.push("supressSubmitWraper");
        }

        function supressSubmitWraper() {
            _spSuppressFormOnSubmitWrapper = true;
        }
    </script>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div style="padding: 15px">
        <wssuc:ToolBar ID="toolBarMain" runat="server" CssClass="ms-toolbar">
            <Template_Buttons>
                <wssuc:ToolBarButton runat="server" Text="Refresh" ID="btnRefresh" ToolTip="Refresh"
                    NavigateUrl="javascript:refreshCurrentLocation();" ImageUrl="/_layouts/images/SPPropertyBagManagement/refresh.gif"
                    Padding="2px" />
                <wssuc:ToolBarButton runat="server" Text="Add new property" ID="btnAddNewProp" ToolTip="Add new property"
                    ImageUrl="/_layouts/images/SPPropertyBagManagement/new.gif" Padding="2px" />
                <wssuc:ToolBarButton runat="server" Text="Export to XML" ID="btnExport" ToolTip="Export to XML"
                    ImageUrl="/_layouts/images/SPPropertyBagManagement/xml.gif" Padding="2px" OnClick="btnExport_OnClick" />
            </Template_Buttons>
        </wssuc:ToolBar>
        <br />
        <br />
        <SharePoint:MenuTemplate ID="menuMain" runat="server">
            <SharePoint:MenuItemTemplate ID="editPropertyMenuItem" runat="server" Text="Edit property"
                ImageUrl="/_layouts/images/SPPropertyBagManagement/edit.gif" />
            <SharePoint:MenuItemTemplate ID="deletePropertyMenuItem" runat="server" Text="Delete property"
                ImageUrl="/_layouts/images/SPPropertyBagManagement/delete.gif" />
        </SharePoint:MenuTemplate>
        <SharePoint:SPGridView ID="grdMain" runat="server" AutoGenerateColumns="false" AllowGrouping="false"
            AllowPaging="False" DataKeyNames="PropertyName,PropertyValue,IsPropertyNameSupported,IsPropertyValueSupported">
            <AlternatingRowStyle CssClass="ms-alternatingstrong" />
            <Columns>
                <SharePoint:SPMenuField HeaderText="Property Name" TextFields="PropertyName" MenuTemplateId="menuMain"
                    HeaderStyle-Font-Bold="True" NavigateUrlFields="" NavigateUrlFormat="" TokenNameAndValueFields="PROPERTYID=PropertyName" />
                <SharePoint:SPBoundField HeaderText="Property Value" DataField="PropertyValue" HeaderStyle-Font-Bold="True" />
                <SharePoint:SPBoundField HeaderText="Property Type" DataField="ValueTypeCode" HeaderStyle-Font-Bold="True" />
            </Columns>
        </SharePoint:SPGridView>
    </div>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
</asp:Content>
